package cbcc2007.compiladores.fkt.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class FileUtil {

	public static String abreArquivo(File arquivo){

		StringBuilder conteudo = new StringBuilder();
		BufferedReader entrada = null;
		
		try {
			
			entrada = new BufferedReader(new FileReader(arquivo));
			String line = null;

			while((line = entrada.readLine()) != null){
				conteudo.append(line+System.getProperty("line.separator"));
			}
			
			entrada.close();

		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		return conteudo.toString();
	}

	
	public static void main(String[] args) {
	
		File teste = new File("C:\\teste.txt");
		System.out.println(abreArquivo(teste));
		
	}
	
}
